package com.smartwebee.android.blespp.hospital;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.smartwebee.android.blespp.BleSppActivity;
import com.smartwebee.android.blespp.R;
import com.smartwebee.android.blespp.utils.Utils;

import static com.smartwebee.android.blespp.utils.Utils.MODE_TYPE;

public class ModeSelectingActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btnMode1;
    private Button btnMode2;
    private Button btnMode3;
    private Button btnMode4;
    private Button btnMode5;
    private Button btnMode6;
    private Button btnMode7;
    private Button btnMode8;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mode_selecting);
        initView();
    }

    private void initView() {
        btnMode1 = (Button)findViewById(R.id.btn_mode1);
        btnMode2 = (Button)findViewById(R.id.btn_mode2);
        btnMode3 = (Button)findViewById(R.id.btn_mode3);
        btnMode4 = (Button)findViewById(R.id.btn_mode4);
        btnMode5 = (Button)findViewById(R.id.btn_mode5);
        btnMode6 = (Button)findViewById(R.id.btn_mode6);
        btnMode7 = (Button)findViewById(R.id.btn_mode7);
        btnMode8 = (Button)findViewById(R.id.btn_mode8);
        findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        btnMode1.setOnClickListener(this);
        btnMode2.setOnClickListener(this);
        btnMode3.setOnClickListener(this);
        btnMode4.setOnClickListener(this);
        btnMode5.setOnClickListener(this);
        btnMode6.setOnClickListener(this);
        btnMode7.setOnClickListener(this);
        btnMode8.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(ModeSelectingActivity.this, HospitalIndexActivity.class);
        intent.putExtra(BleSppActivity.EXTRAS_DEVICE_NAME, getIntent().getStringExtra(BleSppActivity.EXTRAS_DEVICE_NAME));
        intent.putExtra(BleSppActivity.EXTRAS_DEVICE_ADDRESS, getIntent().getStringExtra(BleSppActivity.EXTRAS_DEVICE_ADDRESS));
        switch (v.getId()) {
            case R.id.btn_mode1:
                intent.putExtra(MODE_TYPE, Utils.MODE_1);
                break;
            case R.id.btn_mode2:
                intent.putExtra(MODE_TYPE, Utils.MODE_2);
                break;
            case R.id.btn_mode3:
                intent.putExtra(MODE_TYPE, Utils.MODE_3);
                break;
            case R.id.btn_mode4:
                intent.putExtra(MODE_TYPE, Utils.MODE_4);
                break;
            case R.id.btn_mode5:
                intent.putExtra(MODE_TYPE, Utils.MODE_5);
                break;
            case R.id.btn_mode6:
                intent.putExtra(MODE_TYPE, Utils.MODE_6);
                break;
            case R.id.btn_mode7:
                Toast.makeText(ModeSelectingActivity.this, "该模式暂不支持", Toast.LENGTH_SHORT).show();
                return;
            case R.id.btn_mode8:
                intent.putExtra(MODE_TYPE, Utils.MODE_8);
                break;
        }
        startActivity(intent);
    }
}
